// ++++++++++++++++++++++++++++++++++++++++
// 《Go 语言+Vue.js 实战派——基于 Gin 框架》源码
// ++++++++++++++++++++++++++++++++++++++++
// 作者公众号：源码大数据
// 自媒体账号（抖音、视频号、快手、B站、知乎）：廖显东-ShirDon
// 仓库地址：https://gitee.com/shirdonl/goGinVue.git
// 仓库地址：https://github.com/shirdonl/goGinVue.git
// 博客：https://www.shirdon.com
// 购买图书：https: //item.jd.com/14958064.html
// ++++++++++++++++++++++++++++++++++++++++

package main

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func main() {
	r := gin.Default()

	r.GET("/header1", func(c *gin.Context) {
		// 设置HTTP响应头
		c.Header("X-Custom-Header", "This is a Gin header")

		// ...自定义逻辑
		c.String(200, "Response with custom header")
	})

	r.GET("/header2", func(c *gin.Context) {
		c.Header("X-Header-One", "Test1")
		c.Header("X-Header-Two", "Test2")

		// ...自定义逻辑
		c.String(200, "Response with multiple headers")
	})

	r.GET("/header3", func(c *gin.Context) {
		// 重定向前设置标头
		c.Header("Cache-Control", "no-cache, no-store, must-revalidate")

		// ...自定义逻辑
		c.Redirect(http.StatusTemporaryRedirect, "/new-location")
	})

	r.Run()
}
